﻿using System;
using System.IO;
using System.Runtime.Serialization;
using UnityEngine;

namespace SEXY
{
	// Token: 0x020002A4 RID: 676
	[Serializable]
	public abstract class CharFileInfoClothes
	{
		// Token: 0x06001115 RID: 4373 RVA: 0x0006D770 File Offset: 0x0006B970
		public CharFileInfoClothes(string fileMarkName, string fileDirectory, int cknum)
		{
			this.ClothesFileMark = fileMarkName;
			this.ClothesFileDirectory = fileDirectory;
			this.clothesKindNum = cknum;
			this.clothesId = new int[this.clothesKindNum];
			this.clothesColor = new HSColorSet[this.clothesKindNum];
			this.clothesColor2 = new HSColorSet[this.clothesKindNum];
			this.accessory = new CharFileInfoClothes.Accessory[10];
			for (int i = 0; i < this.accessory.Length; i++)
			{
				this.accessory[i] = new CharFileInfoClothes.Accessory();
			}
			this.comment = "コーディネート名";
		}

		// Token: 0x1700019E RID: 414
		// (get) Token: 0x06001116 RID: 4374 RVA: 0x0006D838 File Offset: 0x0006BA38
		// (set) Token: 0x06001117 RID: 4375 RVA: 0x0006D840 File Offset: 0x0006BA40
		public CharFileInfoClothes.Accessory[] accessory
		{
			get
			{
				return this._accessory;
			}
			private set
			{
				this._accessory = value;
			}
		}

		// Token: 0x06001118 RID: 4376 RVA: 0x0006D84C File Offset: 0x0006BA4C
		protected void MemberInitialize()
		{
		}

		// Token: 0x06001119 RID: 4377
		public abstract bool Copy(CharFileInfoClothes srcData);

		// Token: 0x0600111A RID: 4378 RVA: 0x0006D850 File Offset: 0x0006BA50
		public bool Load(string path, bool noSetPng = false)
		{
			bool result = false;
			if (!File.Exists(path))
			{
				return result;
			}
			this.clothesFileName = Path.GetFileName(path);
			bool result2;
			using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
			{
				using (BinaryReader binaryReader = new BinaryReader(fileStream))
				{
					result2 = this.Load(binaryReader, noSetPng);
				}
			}
			return result2;
		}

		// Token: 0x0600111B RID: 4379 RVA: 0x0006D8D4 File Offset: 0x0006BAD4
		public bool Load(TextAsset ta, bool noSetPNG = false)
		{
			if (null == ta)
			{
				return false;
			}
			bool result;
			using (MemoryStream memoryStream = new MemoryStream())
			{
				memoryStream.Write(ta.bytes, 0, ta.bytes.Length);
				memoryStream.Seek(0L, SeekOrigin.Begin);
				result = this.Load(memoryStream, noSetPNG);
			}
			return result;
		}

		// Token: 0x0600111C RID: 4380 RVA: 0x0006D940 File Offset: 0x0006BB40
		public bool Load(Stream st, bool noSetPNG = false)
		{
			bool result;
			using (BinaryReader binaryReader = new BinaryReader(st))
			{
				result = this.Load(binaryReader, noSetPNG);
			}
			return result;
		}

		// Token: 0x0600111D RID: 4381 RVA: 0x0006D980 File Offset: 0x0006BB80
		public bool Load(BinaryReader br, bool noSetPng = false)
		{
			long num = 0L;
			if (noSetPng)
			{
				PngAssist.CheckPngData(br, ref num, true);
			}
			else
			{
				this.clothesPNG = PngAssist.LoadPngData(br);
			}
			if (!this.LoadWithoutPNG(br))
			{
				return false;
			}
			num = br.ReadInt64();
			return true;
		}

		// Token: 0x0600111E RID: 4382 RVA: 0x0006D9C8 File Offset: 0x0006BBC8
		public bool LoadWithoutPNG(BinaryReader br)
		{
			if (br.BaseStream.Length - br.BaseStream.Position == 0L)
			{
				GlobalData.Debug_LogWarning("可能只是一个PNG文件");
				return false;
			}
			string a = br.ReadString();
			if (a != this.ClothesFileMark)
			{
				GlobalData.Debug_LogError("不同类型的文件。");
				return false;
			}
			this.clothesLoadFileVersion = br.ReadInt32();
			if (this.clothesLoadFileVersion > 3)
			{
				GlobalData.Debug_LogError("比可执行文件更新的角色文件。");
				return false;
			}
			int num = br.ReadInt32();
			int num2 = br.ReadInt32();
			for (int i = 0; i < num2; i++)
			{
				this.clothesId[i] = br.ReadInt32();
				this.clothesColor[i].Load(br, num);
				if (3 <= this.clothesLoadFileVersion)
				{
					this.clothesColor2[i].Load(br, num);
				}
			}
			num2 = br.ReadInt32();
			for (int j = 0; j < num2; j++)
			{
				this.accessory[j].Load(br, this.clothesLoadFileVersion, num);
			}
			if (2 <= this.clothesLoadFileVersion)
			{
				this.comment = br.ReadString();
				this.clothesTypeSex = br.ReadByte();
			}
			return this.LoadSub(br, this.clothesLoadFileVersion, num);
		}

		// Token: 0x0600111F RID: 4383
		protected abstract bool LoadSub(BinaryReader br, int clothesVer, int colorVer);

		// Token: 0x040012AE RID: 4782
		public const int ClothesFileVersion = 3;

		// Token: 0x040012AF RID: 4783
		public readonly string ClothesFileMark = string.Empty;

		// Token: 0x040012B0 RID: 4784
		public readonly string ClothesFileDirectory = string.Empty;

		// Token: 0x040012B1 RID: 4785
		public byte[] clothesPNG;

		// Token: 0x040012B2 RID: 4786
		public string clothesFileName = string.Empty;

		// Token: 0x040012B3 RID: 4787
		public int clothesLoadFileVersion;

		// Token: 0x040012B4 RID: 4788
		public readonly int clothesKindNum;

		// Token: 0x040012B5 RID: 4789
		public int[] clothesId;

		// Token: 0x040012B6 RID: 4790
		public HSColorSet[] clothesColor;

		// Token: 0x040012B7 RID: 4791
		public HSColorSet[] clothesColor2;

		// Token: 0x040012B8 RID: 4792
		public string comment = string.Empty;

		// Token: 0x040012B9 RID: 4793
		public byte clothesTypeSex;

		// Token: 0x040012BA RID: 4794
		private CharFileInfoClothes.Accessory[] _accessory;

		// Token: 0x020002A5 RID: 677
		[Serializable]
		public class Accessory : ISerializable
		{
			// Token: 0x06001120 RID: 4384 RVA: 0x0006DB04 File Offset: 0x0006BD04
			public Accessory()
			{
			}

			// Token: 0x06001121 RID: 4385 RVA: 0x0006DB68 File Offset: 0x0006BD68
			protected Accessory(SerializationInfo info, StreamingContext context)
			{
				this.type = info.GetInt32("type");
				this.id = info.GetInt32("id");
				this.parentKey = info.GetString("parentKey");
				this.addPos.x = info.GetSingle("addPosX");
				this.addPos.y = info.GetSingle("addPosY");
				this.addPos.z = info.GetSingle("addPosZ");
				this.addRot.x = info.GetSingle("addRotX");
				this.addRot.y = info.GetSingle("addRotY");
				this.addRot.z = info.GetSingle("addRotZ");
				this.addScl.x = info.GetSingle("addSclX");
				this.addScl.y = info.GetSingle("addSclY");
				this.addScl.z = info.GetSingle("addSclZ");
				this.color.hsvDiffuse.H = info.GetSingle("diffuseH");
				this.color.hsvDiffuse.S = info.GetSingle("diffuseS");
				this.color.hsvDiffuse.V = info.GetSingle("diffuseV");
				this.color.alpha = info.GetSingle("alpha");
				this.color.hsvSpecular.H = info.GetSingle("specularH");
				this.color.hsvSpecular.S = info.GetSingle("specularS");
				this.color.hsvSpecular.V = info.GetSingle("specularV");
				this.color.specularIntensity = info.GetSingle("specularIntensity");
				this.color.specularSharpness = info.GetSingle("specularSharpness");
				this.color2.hsvDiffuse.H = info.GetSingle("diffuseH2");
				this.color2.hsvDiffuse.S = info.GetSingle("diffuseS2");
				this.color2.hsvDiffuse.V = info.GetSingle("diffuseV2");
				this.color2.alpha = info.GetSingle("alpha2");
				this.color2.hsvSpecular.H = info.GetSingle("specularH2");
				this.color2.hsvSpecular.S = info.GetSingle("specularS2");
				this.color2.hsvSpecular.V = info.GetSingle("specularV2");
				this.color2.specularIntensity = info.GetSingle("specularIntensity2");
				this.color2.specularSharpness = info.GetSingle("specularSharpness2");
			}

			// Token: 0x06001122 RID: 4386 RVA: 0x0006DE8C File Offset: 0x0006C08C
			public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
			{
				info.AddValue("type", this.type);
				info.AddValue("id", this.id);
				info.AddValue("parentKey", this.parentKey);
				info.AddValue("addPosX", this.addPos.x);
				info.AddValue("addPosY", this.addPos.y);
				info.AddValue("addPosZ", this.addPos.z);
				info.AddValue("addRotX", this.addRot.x);
				info.AddValue("addRotY", this.addRot.y);
				info.AddValue("addRotZ", this.addRot.z);
				info.AddValue("addSclX", this.addScl.x);
				info.AddValue("addSclY", this.addScl.y);
				info.AddValue("addSclZ", this.addScl.z);
				info.AddValue("diffuseH", this.color.hsvDiffuse.H);
				info.AddValue("diffuseS", this.color.hsvDiffuse.S);
				info.AddValue("diffuseV", this.color.hsvDiffuse.V);
				info.AddValue("alpha", this.color.alpha);
				info.AddValue("specularH", this.color.hsvSpecular.H);
				info.AddValue("specularS", this.color.hsvSpecular.S);
				info.AddValue("specularV", this.color.hsvSpecular.V);
				info.AddValue("specularIntensity", this.color.specularIntensity);
				info.AddValue("specularSharpness", this.color.specularSharpness);
				info.AddValue("diffuseH2", this.color2.hsvDiffuse.H);
				info.AddValue("diffuseS2", this.color2.hsvDiffuse.S);
				info.AddValue("diffuseV2", this.color2.hsvDiffuse.V);
				info.AddValue("alpha2", this.color2.alpha);
				info.AddValue("specularH2", this.color2.hsvSpecular.H);
				info.AddValue("specularS2", this.color2.hsvSpecular.S);
				info.AddValue("specularV2", this.color2.hsvSpecular.V);
				info.AddValue("specularIntensity2", this.color2.specularIntensity);
				info.AddValue("specularSharpness2", this.color2.specularSharpness);
			}

			// Token: 0x06001123 RID: 4387 RVA: 0x0006E15C File Offset: 0x0006C35C
			public void MemberInitialize()
			{
				this.type = -1;
				this.id = -1;
				this.parentKey = string.Empty;
				this.addPos = Vector3.zero;
				this.addRot = Vector3.zero;
				this.addScl = Vector3.one;
				this.color = new HSColorSet();
				this.color2 = new HSColorSet();
			}

			// Token: 0x06001124 RID: 4388 RVA: 0x0006E1BC File Offset: 0x0006C3BC
			public void Copy(CharFileInfoClothes.Accessory src)
			{
				this.type = src.type;
				this.id = src.id;
				this.parentKey = src.parentKey;
				this.addPos = src.addPos;
				this.addRot = src.addRot;
				this.addScl = src.addScl;
				this.color.Copy(src.color);
				this.color2.Copy(src.color2);
			}

			// Token: 0x06001125 RID: 4389 RVA: 0x0006E234 File Offset: 0x0006C434
			public void Load(BinaryReader reader, int verClothes, int verColor)
			{
				this.type = reader.ReadInt32();
				this.id = reader.ReadInt32();
				this.parentKey = reader.ReadString();
				this.addPos.x = reader.ReadSingle();
				this.addPos.y = reader.ReadSingle();
				this.addPos.z = reader.ReadSingle();
				this.addRot.x = reader.ReadSingle();
				this.addRot.y = reader.ReadSingle();
				this.addRot.z = reader.ReadSingle();
				this.addScl.x = reader.ReadSingle();
				this.addScl.y = reader.ReadSingle();
				this.addScl.z = reader.ReadSingle();
				this.color.Load(reader, verColor);
				if (3 <= verClothes)
				{
					this.color2.Load(reader, verColor);
				}
			}

			// Token: 0x040012BB RID: 4795
			public int type = -1;

			// Token: 0x040012BC RID: 4796
			public int id = -1;

			// Token: 0x040012BD RID: 4797
			public string parentKey = string.Empty;

			// Token: 0x040012BE RID: 4798
			public Vector3 addPos = Vector3.zero;

			// Token: 0x040012BF RID: 4799
			public Vector3 addRot = Vector3.zero;

			// Token: 0x040012C0 RID: 4800
			public Vector3 addScl = Vector3.one;

			// Token: 0x040012C1 RID: 4801
			public HSColorSet color = new HSColorSet();

			// Token: 0x040012C2 RID: 4802
			public HSColorSet color2 = new HSColorSet();
		}
	}
}
